<template>
	<view :style="{ '--color': vuex_config.themeColor1, '--price': vuex_config.price }">
		<view class="memberList" v-if="!parameter.layout || parameter.layout == 1">
			<view class="memberList-box" v-for="(item, index) in dataList" :key="index" @click="open(item)">
				<view class="thimg">
					<image mode="aspectFill" class="img" :src="item.img ? item.img.split(',')[0] : ''"></image>
				</view>
				<view class="details">
					<view class="details_title u-line-1">{{ item.name }}</view>
					<view class="salesVolume" v-if="vuex_config.sales_volume == 1 && item.order_count > 0">
						已售{{ item.order_count }}+</view>
					<view class="price-box">
						<view class="price">
							<text class="price-icon">￥</text>
							<text class="price-num">{{ item.price }}</text>
							<text class="price-link" v-if="item.cost_price > item.price">￥{{ item.cost_price }}</text>
						</view>
						<view class="cart_icon iconfont iconfont-e73d"></view>
					</view>
				</view>
			</view>
		</view>

		<view class="vip_list" v-if="!parameter.layout || parameter.layout == 2">
			<view class="vip-item" @click="open(item)" v-for="(item, index) in dataList" :key="index">
				<image class="item-img" :src="item.img" mode="aspectFill"></image>
				<view class="item-right">
					<view class="title u-line-2">{{ item.name }}</view>
					<view class="item_bot">
						<view class="price">
							<view class="present-price">
								<text class="u-font-28 icon">￥</text>
								<text class="num u-font-42">{{ item.price }}</text>
							</view>
							<view class="Marking-price" v-if="item.cost_price > item.price">￥{{ item.cost_price }}
							</view>
						</view>
						<view class="box-btn">
							<view class="btn">立即购买</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			parameter: {
				type: Object,
				default: () => {
					return {};
				}
			},
			dataList: {
				type: Array,
				default: []
			}
		},
		components: {},
		data() {
			return {};
		},

		mounted() {},

		methods: {
			open(item) {
				this.$toProd({
					...item,
					prodType: 6
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.memberList {
		background-color: #fff;
		padding: 20rpx 26rpx 10rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		.memberList-box {
			width: calc(50% - 12rpx);
			box-shadow: 0px 4rpx 11rpx 2rpx rgba(153, 152, 152, 0.15);
			border-radius: 8rpx;
			overflow: hidden;
			margin-bottom: 20rpx;
			display: flex;
			flex-direction: column;

			.thimg {
				width: 100%;
				height: 0;
				padding-bottom: 74.6%;
				position: relative;

				.img {
					width: 100%;
					height: 100%;
					position: absolute;
					top: 0;
					left: 0;
				}
			}
		}

		.details {
			flex: 1;
			overflow: hidden;
			display: flex;
			flex-direction: column;
			padding: 16rpx;

			.details_title {
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}

			.salesVolume {
				font-size: 24rpx;
				color: #666;
				margin-top: 10rpx;
			}

			.price-box {
				margin-top: auto;
				padding-top: 12rpx;
				display: flex;
				align-items: center;

				.price {
					flex: 1;
					overflow: hidden;

					.price-icon {
						font-size: 24rpx;
						color: #ff1f00;
						font-weight: bold;
					}

					.price-num {
						font-size: 36rpx;
						font-weight: bold;
						color: #ff1f00;
						margin-right: 8rpx;
					}

					.price-link {
						text-decoration: line-through;
						font-size: 26rpx;
						color: #666;
						font-family: PingFang SC;
					}
				}

				.cart_icon {
					color: #ff1f00;
					font-size: 40rpx;
					font-weight: bold;
				}
			}
		}
	}

	.vip_list {
		padding: 10rpx 30rpx 0;
		background-color: #fff;

		.vip-item {
			display: flex;
			padding: 20rpx 0;
			border-bottom: 1px solid #f5f5f5;

			&:first-of-type {
				padding-top: 0;
			}

			&:last-of-type {
				border: none;
			}

			.item-img {
				border-radius: 10rpx;
				overflow: hidden;
				width: 230rpx;
				height: 230rpx;
				margin-right: 20rpx;
			}

			.item-right {
				flex: 1;
				overflow: hidden;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					line-height: 42rpx;
					height: 84rpx;
					padding-top: 2rpx;
				}

				.price {
					display: flex;
					align-items: center;

					.present-price {
						display: flex;
						align-items: center;
						color: var(--price);

						.icon {
							position: relative;
							top: 4rpx;
						}

						.num {
							font-weight: bold;
						}
					}

					.Marking-price {
						text-decoration: line-through;
						font-size: 24rpx;
						color: #999;
						margin-left: 10rpx;
						position: relative;
						top: 4rpx;
					}
				}

				.box-btn {
					width: 100%;
					display: flex;
					margin: 12rpx 0 8rpx;
					justify-content: flex-end;

					.btn {
						padding: 8rpx 26rpx;
						background: var(--color);
						color: #fff;
						text-align: center;
						border-radius: 30rpx;
						font-size: 26rpx;
					}
				}
			}
		}
	}
</style>
